package thread;

public class ThreadStopTest {

	public static void main(String[] args) {
		ThreadStop threadStop = new ThreadStop();
		new Thread(threadStop).start();
		for(int i = 0; i < 100; i++){
			if(i == 50){
				threadStop.stop();
			}
			System.out.println("main-------:"+i);
		}

	}

}

class ThreadStop implements Runnable{

	private boolean flag = true;
	
	@Override
	public void run() {
		while(flag){
			System.out.println("run");
		}
	}
	
	public void stop(){
		flag = false;
		System.out.println("stop thread");
	}
}